#!/bin/bash
echo "检查是否安装docker,docker-compose环境"
docker -v
if [ $? -eq  0 ]; then
 echo "检查到Docker已安装!"
else
 echo "安装docker环境..."
 curl https://gitee.com/ligson/centos7script/raw/master/crux-tools/cruxInstall.sh | bash -s init
fi
if [ ! -d "/data/docker/service/mysql/" ];then
  mkdir -p /data/docker/service/mysql
  else
  echo "/data/docker/service/mysql 文件夹已经存在,请手动确认后删除该目录,载执行创建"
  exit
fi
cd /data/docker/service/mysql
echo "下载镜像包"
wget https://zwfile.yonyougov.top/share/crux-tools/mysql/5.5/mysql5.5images.tar.gz --no-check-certificate
docker load -i mysql5.5images.tar.gz
rm -rf mysql5.5images.tar.gz
echo "下载部署文件"
wget https://zwfile.yonyougov.top/share/crux-tools/mysql/5.5/docker-compose.yml --no-check-certificate
echo "下载mysql配置文件"
mkdir -p /data/docker/service/mysql/data/etc
cd /data/docker/service/mysql/data/etc
wget https://zwfile.yonyougov.tech/share/crux-tools/mysql/5.5/my.cnf --no-check-certificate
cd /data/docker/service/mysql
docker network ls | grep mynetwork
if [ $? -eq  0 ]; then
 echo "Docker网络mynetwork已存在!"
else
 echo "创建docker网络"
 docker network create mynetwork
fi
echo "启动 mysql5.5"
docker-compose up -d
